package com.project.xsf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.common.entity.PageVo;
import com.project.xsf.entity.MDesignProcedureModule;
import com.project.xsf.entity.MProcedure;
import com.project.xsf.mapper.MProcedureMapper;
import com.project.xsf.service.MProcedureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class MProcedureImpl implements MProcedureService {
    @Autowired
    private MProcedureMapper mProcedureMapper;
    @Override
    public int insertSelective(MProcedure record) {
        return mProcedureMapper.insertSelective(record);
    }

    @Override
    public PageVo<MProcedure> queryMProcedureByPId(Map<String,String> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum"));
        Integer pageSize= Integer.valueOf(map.get("pageSize"));
//        System.out.println(map);
        PageHelper.startPage(pageNum,pageSize);
        List<MProcedure> mManufactureId = mProcedureMapper.queryMProcedureByPId(Integer.valueOf(map.get("mManufactureId")));
        PageInfo<MProcedure> pageInfo = new PageInfo<MProcedure>(mManufactureId);

        PageVo<MProcedure> pageVo = new PageVo<MProcedure>();
        pageVo.setRows(pageInfo.getList());
        pageVo.setTotal(pageInfo.getTotal());

        return pageVo;
    }

    @Override
    public List<MProcedure> queryMProcedureByPId(Integer pId) {
        return mProcedureMapper.queryMProcedureByPId(pId);
    }

    @Override
    public MProcedure selectByPrimaryKey(Integer id) {
        return mProcedureMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(MProcedure record) {
        return mProcedureMapper.updateByPrimaryKeySelective(record);
    }
}
